package com.fruit.account.service.excommission;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fruit.mapper.account.excommission.ExceptionCommissionMapper;
import com.fruit.pojo.account.excommission.ExceptionCommission;
/**
 * 返销业务异常处理Service
 * @author Administrator
 *
 */
@Service("commBackLogServiceImpl")
public class CommBackLogServiceImpl {
	protected Logger logger = LoggerFactory.getLogger(CommBackLogServiceImpl.class);
	@Autowired
	private ExceptionCommissionMapper exceptionCommissionMapper;
	
	public void newCommBackLog(ExceptionCommission rec){
		try {
			logger.info("【返销异常处理】---【开始inputparams】---"+rec.toString());
			exceptionCommissionMapper.insert(rec);
			logger.info("【返销异常处理】---【结束】---"+rec.toString());
		} catch (Exception e) {
			logger.info("【返销异常处理】---【异常】---"+ getStackTraceAsString(e));
		}
	}
	
	/**
	 * 将ErrorStack转化为String.
	 */
	public String getStackTraceAsString(Throwable ex) {
		StringWriter stringWriter = new StringWriter();
		ex.printStackTrace(new PrintWriter(stringWriter));
		return stringWriter.toString();
	}
}
